package com.hollycrm.hollysqm.core.index.dao;

import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.common.SolrInputDocument;

public interface IndexSearchDao {

	/**
	 * 返回查询结果ID集合
	 * @param qs
	 * @param paramMap
	 * @param collection
	 * @param sortField
	 * @return
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public List<String> queryResultIds(String qs, Map<String,String> paramMap,final String collection,final String sortField) throws IOException,SolrServerException;
	
	/**
     * 设置高亮显示字段
     * @param field
     */
    public void setHighlightField(String field);
    
    /**
     * 设置高亮显示字段的摘要字数
     * @param field
     */
    public void setHighlightFragsize(int fragsize);
	    
    /**
	 * 设置Solr索引集
	 * @param collection
	 */
	public void setCollection(String collection);
    
    /**
     * 返回查询结果
     * @param qs
     * @param paramMap
     * @param clzss
     * @return
     * @throws IOException
     * @throws SolrServerException
     */
	public <T> List<T> queryResult(String qs, Map<String,String> paramMap,Class<T> clzss) throws IOException,SolrServerException;
	
	/**
     * 返回查询结果ID集合
     * @param qs
     * @param paramMap
     * @return
     * @throws IOException
     * @throws SolrServerException
     */
	public List<String> queryResultIds(String qs, Map<String,String> paramMap) throws IOException,SolrServerException;
	
	/**
	 * 返回查询结果，带高亮显示
	 * @param qs
	 * @param paramMap
	 * @param isHighlight
	 * @param clzss
	 * @return
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public <T> List<T> queryResult(String qs, Map<String,String> paramMap,boolean isHighlight,Class<T> clzss) throws IOException,SolrServerException;
	
	/**
	 * 返回查询结果，带高亮显示,带分页查询
	 * @param qs
	 * @param paramMap
	 * @param start
	 * @param rows
	 * @param isHighlight
	 * @param clzss
	 * @return
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public <T> List<T> queryResult(String qs, Map<String,String> paramMap,int start,int rows,boolean isHighlight,Class<T> clzss) throws IOException,SolrServerException;
		
	/**
	 * 通过ID查询Solr获取指定类型返回对象
	 * @param id 主键
	 * @param clzss 类型
	 * @return T
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public <T>T getById(final String id,final Class<T> clzss) throws IOException,SolrServerException;
	
	/**
	 * 增加文档
	 * @param doc
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public void addDoc(SolrInputDocument doc) throws IOException,SolrServerException;
	
	/**
	 * 批量增加文档
	 * @param doc
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public void addDocs(Collection<SolrInputDocument> docs) throws IOException,SolrServerException;
		
	/**
	 * 将指定的对象更新到Solr中
	 * @param clzss
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public <T> void updateDoc(final T clzss)  throws IOException,SolrServerException;
		
	/**
	 * 通过主键ID删除文档
	 * @param id
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public void deleteById(String id) throws IOException,SolrServerException;
	
	/**
	 * 统计查询结果总数
	 * @param qs
	 * @param paramMap
	 * @return
	 * @throws IOException
	 * @throws SolrServerException
	 */
	public int count(final String qs,final Map<String,String> paramMap) throws IOException,SolrServerException;
		
	
}
